package gov.mogaha.ntis.cmm.mob;

import gov.mogaha.ntis.cmm.mob.util.Logger;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;

public class Ntis_mob_cmmActivity extends Activity {
    /** Called when the activity is first created. */
	static final int JIBUN_SEARCH = 0;
	static final int ROAD_SEARCH = 1;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Button btn = new Button(this);
        btn.setText("지번검색");
        btn.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
        Button btn2 = new Button(this);
        btn2.setText("도로명");
        btn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				startActivityForResult(new Intent(Ntis_mob_cmmActivity.this, CmmMobJibunAddrInsert.class),JIBUN_SEARCH);
			}
		});
        setContentView(btn);
        addContentView(btn2, new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
        btn2.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				startActivityForResult(new Intent(Ntis_mob_cmmActivity.this, CmmMobNewAddrInsert.class),ROAD_SEARCH);
			}
		});
        /**
         * 사용방법 - 주소검색
         */
//        Intent juso = new Intent(this, CmmMobJibunAddrInsert.class);
//        startActivityForResult(juso	, JUSO_SEARCH);
    }
    
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    	// TODO Auto-generated method stub
    	super.onActivityResult(requestCode, resultCode, data);
    	if (resultCode == RESULT_OK) {
			if (requestCode == JIBUN_SEARCH) {
				Address addr = (Address) data.getSerializableExtra("data");
				Logger.i(addr.toString());
			}else if (requestCode == ROAD_SEARCH) {
				Address addr = (Address) data.getSerializableExtra("data");
				Logger.i(addr.toString());
			}
		}
    }
}